local xiongyan = fk.CreateSkill {
  name = "lingling__xiongyan",
}

Fk:loadTranslationTable{
  ["lingling__xiongyan"] = "凶宴",
  [":lingling__xiongyan"] = "每轮限一次，攻击范围内有你的其他角色回合开始时，你可以弃置一张牌令其视为使用【酒】，然后你对其造成1点伤害，"..
  "本回合结束时你令你或其视为使用【桃】。",

  ["#lingling__xiongyan-invoke"] = "凶宴：你可以弃一张牌视为 %dest 使用一张【酒】，然后对其造成1点伤害",
  ["#lingling__xiongyan-choose"] = "凶宴：令你或 %dest 视为使用【桃】",
}

xiongyan:addEffect(fk.TurnStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(xiongyan.name) and
      target:inMyAttackRange(player) and not player:isNude() and not target.dead and
      player:usedSkillTimes(xiongyan.name, Player.HistoryRound) == 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local card = room:askToDiscard(player, {
      min_num = 1,
      max_num = 1,
      include_equip = true,
      skill_name = xiongyan.name,
      cancelable = true,
      prompt = "#lingling__xiongyan-invoke::" .. target.id,
      skip = true,
    })
    if #card > 0 then
      event:setCostData(self, {tos = {target}, cards = card})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard(event:getCostData(self).cards, xiongyan.name, player, player)
    if not target.dead and target:canUseTo(Fk:cloneCard("analeptic"), target) then
      room:useVirtualCard("analeptic", nil, target, target, xiongyan.name, false)
      if target.dead then return end
      room:damage{
        from = player,
        to = target,
        damage = 1,
        skillName = xiongyan.name,
      }
    end
  end,
})

xiongyan:addEffect(fk.TurnEnd, {
  anim_type = "support",
  is_delay_effect = true,
  can_trigger = function (self, event, target, player, data)
    return player:usedSkillTimes(xiongyan.name, Player.HistoryTurn) > 0 and
      not player.dead and (player:canUseTo(Fk:cloneCard("peach"), player) or target:canUseTo(Fk:cloneCard("peach"), target))
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      targets = {player, target},
      skill_name = xiongyan.name,
      prompt = "#lingling__xiongyan-choose::"..target.id,
      cancelable = false,
    })[1]
    room:useVirtualCard("peach", nil, to, to, xiongyan.name)
  end,
})

return xiongyan
